package com.yeren.tarena.practice.ff;
import java.util.Scanner;
public class Oop_21 {
	public static void main(String[] args) {
		System.out.println("8--上升，5--下落，4--左移，6--右移,0--退出");
		Cell c=new Cell(0,19);
		System.out.println("cell的位置为("+c.getX()+","+c.getY()+")");
		hua(c);
		while(true){
			Scanner scanner=new Scanner(System.in);
			int putIn=scanner.nextInt();
			System.out.println("cell的位置为("+c.getX()+","+c.getY()+")");
			hua(c);
			switch(putIn){
			case 8:
				c.up();
				break;
			case 5:
				c.down();
				break;
			case 4:
				c.left();
				break;
			case 6:
				c.right();
				break;
			case 0:
				System.out.println("欢迎下次再来");
				break;
			}
		}
	}

	public static void hua(Cell cell) {
		// 画面板
		for (int i = 0; i < 20; i++) {
			for (int j = 0; j < 10; j++) {
				if (i == cell.getY() && j == cell.getX()) {
					System.out.print("*");
				} else {
					System.out.print("-");
				}
			}
			System.out.println();
		}
	}
}


class Cell{
	private int x;
	private int y;
	//构造函数
	Cell(){
		
	}
	//构造函数
	Cell(int x,int y){
		this.x =x;
		this.y=y;
	}
	public int getX() {
		return x;
	}
	public void setX(int x) {
		this.x = x;
	}
	public int getY() {
		return y;
	}
	public void setY(int y) {
		this.y = y;
	}
	//下落一步
	public int down(){
		y++;
		return y;
	}
	//下落n步
	public int down(int n){
		y=y+n;
		return y;
	}
	//上移一步
	public int up(){
		y--;
		return y;
	}
	//上移n步
	public int up(int n){
		y=y-n;
		return y;
	}
	//左移一步
	public int left(){
		x--;
		return x;
	}
	//左移n步
	public int left(int n){
		x=x-n;
		return x;
	}
	//右移一步
	public int right(){
		x++;
		return x;
	}
	//右移n步
	public int right(int n){
		x=x+n;
		return x;
	}
}



